<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
<title></title>
<style type="text/css">
<!--
body,td,th {
	font-size: 12px;
}
.red{
  color: red;
}
-->
</style>
<script type="text/javascript">
  function checkuser(form){
    var user=form.user.value;
    var Expression1=/^[\u4e00-\u9fa5]{2,4}$/;
    var objExp1=new RegExp(Expression1);
    if(user==""){
      showuser.innerHTML="请输入姓名！";
      return false;
    }else if(objExp1.test(user)==true){
      showuser.innerHTML="";
      return true;
    }else{
      showuser.innerHTML="姓名格式不正确！";
      return false;
    }
  }
  function checktel(form){
    var tel=form.tel.value;
    var Expression4=/^13(\d{9})$|^18(\d{9})$|^15(\d{9})$/;
    var objExp2=new RegExp(Expression4);
    if(tel==""){
      showtel.innerHTML="请输入移动电话号码！";
      return false;
    }else if(objExp2.test(tel)==true){
      showtel.innerHTML="";
      return true;
    }else{
      showtel.innerHTML="移动电话号码格式不正确！";
      return false;
    }
  }
  function checkinput(form){
    if(checkuser(form) && checktel(form)){
      alert("提交成功！");
    }else{
      return false;
    }
  }
</script>
</head>
<body>
<form name="form" method="post" action="#" onsubmit="return checkinput(form)">
姓&emsp;&emsp;名：<input type="text" name="user" size="20" class="inputcss" onBlur="checkuser(form)">
  <span id="showuser" class="red"></span><br>
移动电话：<input type="text" name="tel" size="20" class="inputcss" onBlur="checktel(form)">
  <span id="showtel" class="red"></span><br>
<input type="submit" name="sub" value="提交">
</form>
</body>
</html>
